/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-08-06     RT-Thread    first version
 */

#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>

#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

#define LED_RED      GET_PIN(C, 0)
#define LED_GREEN    GET_PIN(C, 4)


extern int MCmain(void);
int main(void)
{
    int count = 1;

    //MCmain();

    rt_pin_mode( LED_RED, PIN_MODE_OUTPUT);
    rt_pin_mode( LED_GREEN, PIN_MODE_OUTPUT);
    rt_pin_write( LED_RED, PIN_HIGH);


    while (count++)
    {
    //    LOG_D("Hello RT-Thread!");
    //    rt_thread_mdelay(1000);
        rt_pin_write( LED_GREEN, PIN_HIGH);
        rt_thread_mdelay(500);
        rt_pin_write( LED_GREEN, PIN_LOW);
        rt_thread_mdelay(500);
    }

    return RT_EOK;
}

static soongtest(void)
{
#define SAMPLE_UART_NAME       "uart3"    /* 串口设备名称 */
    static rt_device_t serial;                /* 串口设备句柄 */
    char str[] = "hello RT-Thread!\r\n";
    struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; /* 配置参数 */
    /* 查找串口设备 */
    serial = rt_device_find(SAMPLE_UART_NAME);

    /* 以中断接收及轮询发送模式打开串口设备 */
    rt_device_open(serial, RT_DEVICE_FLAG_INT_RX);
    /* 发送字符串 */
    rt_device_write(serial, 0, str, (sizeof(str) - 1));
}
MSH_CMD_EXPORT(soongtest, soongBQ test shell);
